/*
 * ReporteGanancias.java
 *
 * Created on 30 de octubre de 2007, 07:34 PM
 */

package interfaces;

import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import org.freixas.jcalendar.DateEvent;
import org.freixas.jcalendar.DateListener;
import restaurante.ImplReportesGCT;

/**
 *
 * @author Fanny Paola Vadillo Herrera
 * @author Luis Manuel Pineda Llano
 */
public class ReporteClientes extends javax.swing.JPanel implements DateListener {
    
    private ImplReportesGCT irgct = new ImplReportesGCT();
    private InicialReportes ir;
    
    /** Creates new form ReporteGanancias */
    public ReporteClientes(InicialReportes i) {
        ir = i;
        initComponents();
        setPreferredSize(new java.awt.Dimension(800, 600));
        java.util.Date fecha = calendario.getDate();
        grafica.setAlturas(irgct.llenarClientes(clientes, fecha));
        grafica.repaint();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        clientes = new javax.swing.JTable();
        grafica = new MyCanvas();
        calendario = new org.freixas.jcalendar.JCalendar();
        regresar = new javax.swing.JButton();

        setBackground(new java.awt.Color(235, 241, 241));
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setText("Clientela");

        clientes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"09:00:00", ""},
                {"10:00:00", null},
                {"11:00:00", null},
                {"12:00:00", null},
                {"13:00:00", null},
                {"14:00:00", null},
                {"15:00:00", null},
                {"16:00:00", null},
                {"17:00:00", null},
                {"18:00:00", null},
                {"19:00:00", null},
                {"20:00:00", null},
                {"21:00:00", null}
            },
            new String [] {
                "Hora", "No. de Clientes"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        clientes.setFillsViewportHeight(true);
        initColumnSizes();
        jScrollPane1.setViewportView(clientes);

        grafica.setBackground(new java.awt.Color(255, 255, 255));

        calendario.setBackground(new java.awt.Color(235, 241, 241));
        calendario.setDayFont(new java.awt.Font("Tahoma", 0, 8));
        calendario.setFont(new java.awt.Font("Tahoma", 0, 3));
        calendario.setTodayFont(new java.awt.Font("Tahoma", 1, 8));
        calendario.addDateListener(this);

        regresar.setText("< Regresar");
        regresar.setActionCommand("regresar");
        regresar.addActionListener(ir);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addComponent(regresar)
                                .addGap(223, 223, 223))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(calendario, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 311, Short.MAX_VALUE)
                                    .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(grafica))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(370, 370, 370)
                        .addComponent(jLabel1)))
                .addGap(33, 33, 33))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15)
                        .addComponent(calendario, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                        .addComponent(regresar))
                    .addComponent(grafica))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    
    /** Se inicializan las alineaciones de las columnas */
    private void initColumnSizes() {
        TableColumn column = null;
        int headerWidth = 0;
        int cellWidth = 0;
        javax.swing.table.TableModel modelo = clientes.getModel();
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();
        tcr.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        for (int i = 0; i < modelo.getColumnCount(); i++) {
            column = clientes.getColumnModel().getColumn(i);
            column.setCellRenderer(tcr);
        }
    }
    
    public void dateChanged(DateEvent e) {
        java.util.Date fecha = calendario.getDate();
        grafica.setAlturas(irgct.llenarClientes(clientes, fecha));
        grafica.repaint();
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.freixas.jcalendar.JCalendar calendario;
    private javax.swing.JTable clientes;
    private MyCanvas grafica;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton regresar;
    // End of variables declaration//GEN-END:variables
    
}
